package org.jerrymouse.financeApp;

import java.util.List;

import org.jerrymouse.agentContainer.Agent;
import org.jerrymouse.jsa4j.db.kv.JsonUtil;

public class FinanceDB extends Agent {
	JsonUtil<Bean> jsonUtil = new JsonUtil<Bean>();

	public List<Double> getCompanyFinance(String key) {
		Bean bean = jsonUtil.toBean(db.get(key), Bean.class);
		if (bean == null)
			return null;
		return bean.getDoubles();
	}

	public void putCompanyFinance(String key, List<Double> doubles) {
		Bean bean = new Bean();
		bean.setDoubles(doubles);
		db.put(key, jsonUtil.toJson(bean));
	}

	public List<Double> getTradeFinance(String key) {
		Bean bean = jsonUtil.toBean(db.get(key), Bean.class);
		if (bean == null)
			return null;
		return bean.getDoubles();
	}

	public void putTradeFinance(String key, List<Double> doubles) {
		Bean bean = new Bean();
		bean.setDoubles(doubles);
		db.put(key, jsonUtil.toJson(bean));
	}

}

class Bean {
	private List<Double> doubles;

	public void setDoubles(List<Double> doubles) {
		this.doubles = doubles;
	}

	public List<Double> getDoubles() {
		return doubles;
	}
}
